package com.maoning.gulimallsearch.controller;

import com.maoning.gulimallsearch.service.MallSearchService;
import com.maoning.gulimallsearch.vo.SearchParam;
import com.maoning.gulimallsearch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * @Author : 猫宁
 * @Date: 2022/2/10
 */
@Controller
public class SearchController {
    @Autowired
    private MallSearchService mallSearchService;
    @RequestMapping("/list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request){
        final String queryString = request.getQueryString();
        searchParam.setQueryString(queryString);
        SearchResult result = mallSearchService.search(searchParam);
        model.addAttribute("result", result);
        return "list";
    }

}
